package com.handler;

import com.ymx.darling.bean.entity.BeanInfo;
import com.ymx.darling.bean.entity.BeanInfoManager;
import com.ymx.darling.build.mapper.MapperMethodInfoInfoManager;
import com.ymx.darling.build.mapper.method.ProviderMethodInfo;
import com.ymx.darling.session.Session;

/**
 * @author 爱Java的小于
 */
public class SelectAll extends ProviderMethodInfo {
    @Override
    public Object invoke(Class<?> mapperClass, Session session, String sqlStatementId, Object[] param) throws Throwable {
        Class<?> entityType = MapperMethodInfoInfoManager.getEntityType(mapperClass);
        BeanInfo beanInfo = BeanInfoManager.getBeanInfo(entityType);
        // 改成*号的形式
        return session.selectList(entityType, "select *1 from " + beanInfo.getTableName());
    }
}
